from flask_restful import Resource

from restful.api__.session import  login_required_current_user_generate, \
    uid_required_target_user_generate
from restful.model.query import QueryMultipleInstances, QueryOneInstance
from restful.model.tables import Blog, Check
from restful.response import ResponseSuccess


class UserAllPostsUnpassed(Resource):
    @login_required_current_user_generate
    @uid_required_target_user_generate
    def get(self,target_user,current_user):
        posts=QueryMultipleInstances(Blog,{'uid':target_user.id,'checked':True,'passed':False})
        return ResponseSuccess(data=[{
            'pid':i.pid,
            'reason':QueryOneInstance(Check,{'pid':i.pid}).resaon,
        }for i in posts])